//
//  NSString+StringLength.m
//  WestWolves
//
//  Created by JL on 15/12/11.
//  Copyright © 2015年 ZJ. All rights reserved.
//

#import "NSString+StringLength.h"

@implementation NSString (StringLength)
- (CGFloat)stringWidthWithFont:(UIFont *)font andSize:(CGSize)size
{
    NSDictionary *attribute = @{NSFontAttributeName: font};
    CGSize StringSize= [self boundingRectWithSize:size options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
    return StringSize.width +1; // 为了适配手机5，5s计算的尺寸加一
}
- (CGFloat)stringHeightWithFont:(UIFont *)font andSize:(CGSize)size
{
    NSDictionary *attribute = @{NSFontAttributeName: font};
    CGSize StringSize= [self boundingRectWithSize:size options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
    return StringSize.height + 1;// 为了适配手机5，5s计算的尺寸加一
}
- (CGSize)stringSizeWithFont:(UIFont *)font andSize:(CGSize)size
{
    NSDictionary *attribute = @{NSFontAttributeName: font};
    CGSize StringSize= [self boundingRectWithSize:size options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
    return StringSize;
}
@end
